<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <span>name</span>
    <script>
      /* 
        1. 创建MutationObserver实例,传递回调函数
        2. 使用实例的observe方法监听dom对象,配置要监听的变化
      
      */
      const mutationObserver = new MutationObserver(
        (mutationList, observer) => {
          console.log("observer: ", observer);
          console.log("mutationList: ", mutationList);
        }
      );
      const span = document.querySelector("span");
      span.addEventListener("click", () => {
        span.textContent = 111;
      });
      mutationObserver.observe(span, {
        characterData: true,
        attributes: true,
        subtree: true,
        childList: true,
      });
    </script>
  </body>
</html>
